package com.ys.peony.ui.holder;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.ys.peony.R;
import com.ys.peony.interfaces.OnContractClickListener;
import com.ys.peony.model.domain.ContractSortModel;

/**
 * Created by 59153 on 2018/3/27.
 */

public class ContractChildViewHolder extends BaseViewHolder {

    private Context mContext;
    private View view;
    private TextView tv_name;
    private ImageView iv_yq;
    private RelativeLayout rl_item;

    public ContractChildViewHolder(Context context, View itemView) {
        super(itemView);
        this.mContext = context;
        this.view = itemView;
    }

    public void bindView(final ContractSortModel.FileTemplateBean model, final int parentpos, final int childpos, final OnContractClickListener listener) {
        if (model == null
                || model.getBusiFileTemplateList() == null
                || model.getBusiFileTemplateList().size() < 1) {
            return;
        }
        ContractSortModel.FileTemplateBean.BusiFileTemplateListBean bean = model.getBusiFileTemplateList().get(childpos);
        tv_name = view.findViewById(R.id.tv_name);
        iv_yq = view.findViewById(R.id.iv_yq);
        rl_item = view.findViewById(R.id.rl_item);
        tv_name.setText(bean.getName());
        if ("3".equals(bean.getSignStatus())) {
            iv_yq.setVisibility(View.VISIBLE);
            iv_yq.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.contract_yq));
        } else if ("2".equals(bean.getSignStatus())) {
            iv_yq.setVisibility(View.VISIBLE);
            iv_yq.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.contract_dq));
        } else {
            iv_yq.setVisibility(View.INVISIBLE);
        }
        rl_item.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onContractClick(parentpos, childpos);
            }
        });
    }
}
